// 表单提交，阻止默认，获取输入框内容，ajax请求
$('#form').on('submit', function (e) {
    e.preventDefault()
    let data = $(this).serialize()
    console.log(data)
    $.ajax({
        type: 'post',
        url: '/api/login',
        data: data,
        success: function (res) {
            console.log(res)
            layer.msg(res.message, {
                time: 2000
            }, function () {
                if (res.status === 0) {
                    localStorage.setItem('token', res.token)
                    location.href = './index.html'
                }
            })
        }
    })
})